﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BMUpload.Utility
{
    public  class Common
    {
        /// <summary>
        /// 获取当前程序名称
        /// </summary>
        /// <returns></returns>
        public static string GetAppName()
        {
            //return Application.ExecutablePath.Replace(Application.StartupPath + "\\", "");
            return "App";
        }
        /// <summary>
        /// 获取当前程序路径
        /// </summary>
        /// <returns></returns>
        public static string GetAppPath()
        {
            return AppDomain.CurrentDomain.BaseDirectory;
        }


        public static int ConverttoInt(bool value)
        {
            if (value)
            { return 1; }
            else
            { return 0; }
        }


        public static string Left(string sSource, int iLength)
        {
            return sSource.Substring(0, iLength > sSource.Length ? sSource.Length : iLength);
        }

        public static string Right(string sSource, int iLength)
        {
            return sSource.Substring(iLength > sSource.Length ? 0 : sSource.Length - iLength);
        }

        public static string Mid(string sSource, int iStart, int iLength)
        {
            int iStartPoint = iStart > sSource.Length ? sSource.Length : iStart;
            return sSource.Substring(iStartPoint, iStartPoint + iLength > sSource.Length ? sSource.Length - iStartPoint : iLength);
        }
    }
}
